import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(
    home: Scaffold(
      appBar: AppBar(
        title: const Text("ConstrainedBox Demo"),
      ),
      body: UnconstrainedBoxWidget(),
    ),
  ));
}

class UnconstrainedBoxWidget extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return ConstrainedBox(
      //  多重限制，取父子组件限制中最大值
      constraints: const BoxConstraints(
        minWidth: 300.0,
        minHeight: 300.0,
      ),
      child: UnconstrainedBox(
        child: ConstrainedBox(
          constraints: const BoxConstraints(
            minWidth: 100.0,
            minHeight: 100.0,
          ),
          child: Container(
            // Container的高度设置为5像素，但是最终却是50像素，这正是ConstrainedBox的最小高度限制生效了
            height: 1.0,
            width: 1.0,
            child: null,
            color: Colors.red,
          ),
        ),
      ),
    );
  }
}